import java.sql.ClientInfoStatus;
import java.util.ArrayList;
import java.util.Scanner;


public class zuoye {

    public static void main(String[] args) {

            ArrayList<Goods> list = new ArrayList<Goods>();
                addStore(list);

                while (true) {
                    int choose = chooseFunction();
                    switch (choose) {
                        case 1:
                            printStore(list);
                            break;
                        case 2:
                            undate(list);
                            break;
                        case 3:
                            exit(list);
                            return;
                        case 4:
                            addStore1(list);
                        default:
                            System.out.println("输入错误");
                            break;
                    }
                }
            }

    private static void addStore1(ArrayList<Goods> list) {
        Goods g3=new Goods();
        g3.name="苹果";
        g3.size=600;
        g3.price=500;
        g3.count=7;
        Goods g4=new Goods();
        g4.count=700;
        g4.price=200;
        g4.size=800;
        g4.name="华为";
        list.add(g3);
        list.add(g4);

        int totalCount=0;
        double totalMoney=0.0;

        System.out.println("=======库存清单=======");
        System.out.println("商品名称         商品规格       商品价格         商品数量");

        for (int i = 0;i< list.size();i++){
            Goods item=list.get(i);
            System.out.println(item.name+"     "+item.size+"        "+item.price+"       "+item.count);
            totalCount+=item.count;
            totalMoney+=item.price*item.count;
        }
        System.out.println("总数量"+totalCount);
        System.out.println("总金额"+totalMoney);
    }


    private static void addStore( ArrayList<Goods> list) {
        Goods g=new Goods();
        g.name="小米";
        g.size=200;
        g.price=300;
        g.count=4;
        Goods g1=new Goods();
        g1.count=100;
        g1.price=400;
        g1.size=500;
        g1.name="小米2";
        list.add(g);
        list.add(g1);


    }

    private static void exit(ArrayList<Goods> list) {
        System.out.println("退出");
    }

    private static void undate(ArrayList<Goods> list) {
        System.out.println("修改商品数量");
        for (int i=0;i<list.size();i++){
            Goods item=list.get(i);
            System.out.println("请输入"+item.name+"的库存");
            item.count=new Scanner(System.in).nextInt();
            list.set(i,item);

        }
    }

    private static void printStore(ArrayList<Goods> list) {
        int totalCount=0;
        double totalMoney=0.0;

        System.out.println("=======库存清单=======");
        System.out.println("商品名称         商品规格       商品价格         商品数量");

        for (int i = 0;i< list.size();i++){
            Goods item=list.get(i);
            System.out.println(item.name+"     "+item.size+"        "+item.price+"       "+item.count);
            totalCount+=item.count;
            totalMoney+=item.price*item.count;
        }
        System.out.println("总数量"+totalCount);
        System.out.println("总金额"+totalMoney);
    }

    private static int chooseFunction() {
        System.out.println("库存管理系统");
        System.out.println("库存清单");
        System.out.println("修改库存清单");
        System.out.println("关闭");
        int choose=new Scanner(System.in).nextInt();
        return choose;

    }

        }